package com.freesky.biz.icbc.service.impl;

import com.alibaba.fastjson2.JSON;
import com.freesky.biz.icbc.domain.TScanBusi;
import com.freesky.biz.icbc.domain.TScanUser;
import com.freesky.biz.icbc.mapper.ScanBusiMapper;
import com.freesky.biz.icbc.service.IScanBusiService;
import com.freesky.common.constant.UserConstants;
import com.freesky.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScanBusiServiceImpl implements IScanBusiService {

    @Autowired
    private ScanBusiMapper scanBusiMapper;

    @Override
    public int insertScanBusi(TScanBusi scanBusi) {
        return scanBusiMapper.insertScanBusi(scanBusi);
    }

    @Override
    public int updateScanBusi(TScanBusi scanBusi) {
        return scanBusiMapper.updateScanBusi(scanBusi);
    }

    @Override
    public List<TScanBusi> selectScanBusiList(TScanBusi scanBusi) {
        return scanBusiMapper.selectScanBusiList(scanBusi);
    }

    @Override
    public int deleteScanBusiById(Long[] scanBusiIds) {
        return scanBusiMapper.deleteScanBusiById(scanBusiIds);
    }

    @Override
    public TScanBusi selectScanBusiById(Long busiId) {
        return scanBusiMapper.selectScanBusiById(busiId);
    }


    @Override
    public boolean checkScanBusiCodeUnique(TScanBusi scanBusi) {
        TScanBusi scanBusi2 = scanBusiMapper.checkScanBusiCodeUnique(scanBusi.getBusiCode());
        //System.out.println(JSON.toJSONString(scanBusi2));
        //System.out.println(JSON.toJSONString(scanBusi));
        if (StringUtils.isNotNull(scanBusi2) && !scanBusi2.getBusiId().equalsIgnoreCase(scanBusi.getBusiId())) {
            return UserConstants.NOT_UNIQUE;
        }

        return UserConstants.UNIQUE;
    }
}
